package org.jeecg.modules.monitoring.j_monitoring.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.monitoring.j_monitoring.entity.EquipmentData;
import org.jeecg.modules.monitoring.j_monitoring.mapper.EquipmentDataMapper;
import org.jeecg.modules.monitoring.j_monitoring.mapper.FreeMapper;
import org.jeecg.modules.monitoring.j_monitoring.service.IEquipmentDataService;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import jakarta.annotation.Resource;
import java.util.List;

/**
 * @Description: 设备选择表
 * @Author: xiaoyq
 * @Date:   2023-04-12
 * @Version: V1.0
 */
@Service
@EnableScheduling
public class EquipmentDataServiceImpl extends ServiceImpl<EquipmentDataMapper, EquipmentData> implements IEquipmentDataService {

    @Resource
    private FreeMapper freeMapper;


    public void syncData(){
        List<String> ids = baseMapper.selectIds();
        List<EquipmentData> sqlserverList = this.getSqlServiceAllList();
        for (EquipmentData data : sqlserverList){
            if (!ids.contains(data.getId())){
                baseMapper.insertIgnore(data);
            }
        }
    }

    public List<EquipmentData> getSqlServiceAllList(){
        return freeMapper.selectEquipmentAllList();
    }


}
